﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using BBICMS.Model;
using BBICMS.Repository;
using BBICMS.Model.ViewModel;

namespace BBICMS.WebUI.Controllers.api
{

    public class WorksController : ApiController
    {
        private ApplicationUnit _unit = new ApplicationUnit();
        // GET: api/Works
        public IEnumerable<WorkListVM> Get()
        {
            var works = (from w in _unit.Works.GetAll()
                         select new WorkListVM
                {
                    WorkId = w.Id,
                    Title = w.Title,
                    Thumbnail = w.Thumbnail,
                    AddedDate = w.AddedDate
                }).OrderByDescending(w => w.AddedDate).ToList();
            return works;
        }

        // GET: api/Works/5
        public string Get(int id)
        {
            return "value";
        }

        // POST: api/Works
        public void Post([FromBody]string value)
        {
        }

        // PUT: api/Works/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE: api/Works/5
        public void Delete(int id)
        {
        }
    }
}
